﻿namespace Budgetsch.WP7.Model.Live
{
    using System;
    using System.Collections.Generic;
    using Budgetsch.WP7.Model.DataService;
    using Budgetsch.WP7.ViewModel;
    using Budgetsch.WP7.WP7DataService;

    public class CostDataService : ICostDataService
    {
        private readonly CookieContainerViewModel _cookieContainer;

        public CostDataService(CookieContainerViewModel cookieContainer)
        {
            _cookieContainer = cookieContainer; 
        }

        #region Implementation of ICostDataService

        public void GetCosts(Action<IEnumerable<Cost>, Exception> callback)
        {
            var client = new WP7DataServiceClient { CookieContainer = this._cookieContainer.CookieContainer };
            client.GetCostsCompleted += (s, e) => callback(e.Result, e.Error);
            client.GetCostsAsync();
        }


        #endregion
    }
}
